package tcu.iot.gasmanage.mapper;

import org.apache.ibatis.annotations.*;
import tcu.iot.gasmanage.entity.Token;

@Mapper
public interface TokenMapper {

    @Insert("INSERT INTO token(tokenId,tokenUsername,token,buildTime,limitTime) VALUES (#{tokenId},#{tokenUsername},#{token},#{buildTime},#{limitTime})")
    void InsertToken(Token token);

    @Delete("DELETE FROM token WHERE tokenUsername=#{tokenUsername}")
    boolean DeleteToken(String tokenUsername);

    @Update("UPDATE token SET tokenId=#{tokenId},token=#{token},buildTime=#{buildTime},limitTime=#{limitTime} WHERE tokenUsername=#{tokenUsername}")
    void UpdateToken(Token token);

    @Select("SELECT * FROM token WHERE tokenId=#{tokenId}")
    Token getById(String tokenId);

    @Select("SELECT * FROM token WHERE tokenUsername=#{tokenUsername}")
    Token getByTokenUsername(String tokenUsername);
}
